package cn.amossun.starter.mybatis.data.security.config;

import cn.hutool.core.collection.CollectionUtil;
import cn.amossun.starter.mybatis.data.security.runner.CacheRunner;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @description:
 * @author: Amos.Sun
 * @DateTime: 2020/05/31 11:48
 **/
@Component
public class InitParameter implements ApplicationRunner {

    @Autowired(required = false)
    private List<CacheRunner> cacheRunnerList;

    /**
     * 项目启动的时候初始化参数
     * @param args
     * @throws Exception
     */
    @Override
    public void run(ApplicationArguments args) throws Exception {

        if(CollectionUtil.isNotEmpty(cacheRunnerList)) {
            for(CacheRunner cacheRunner : cacheRunnerList) {
                cacheRunner.initCache();
            }
        }

    }

}
